<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1-999之间个位，十位，百位都相等的数相加之合
        //     var res = 0
        //     for(a=100;a<=999;a++){
        //         if(a%111==0){
        //             res +=a
        //         }
        //     }
        //     console.log(res)



        var res = ""
        var num = "2"
        var total = 0     
         for(a=1;a<=4;a++){
            res +=num
            console.log(res)
            total +=Number(res)
        }
        console.log(total)

    </script>
</body>

</html>